<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>圣杯布局</title>
    <style>
        body {
            text-align: center;
        }

        header {
            background-color: #ed1250;
        }

        .main {
            width: 100%;
            height: 200px;
            background-color: green;
        }

        .left {
            width: 300px;
            margin-left: -100%;
            background-color: yellow;
            position: relative;
            /*因为width为300，
            所以wrapper的padding为300，
            所以这里为300*/
            left: -300px;
        }

        .right {
            width: 300px;
            margin-left: -300px;
            background-color: pink;
            position: relative;
            right: -300px;
        }

        footer {
            background-color: purple;
        }

        .main, .left, .right {
            float: left;
        }

        /*清除浮动塌陷*/
        .clearfix::after {
            content: "";
            display: block;
            clear: both;
        }

        .wrapper {
            padding: 0 300px;
        }
    </style>
</head>
<body>
<header>头部</header>
<div class="clearfix wrapper">
    <div class="main">主区域</div>
    <div class="left">左区域</div>
    <div class="right">右区域</div>
</div>
<footer>底部</footer>
</body>
</html>

